﻿# coding=UTF-8
from appengine_django import models
from google.appengine.ext import db

class Category(models.BaseModel):
    name = db.StringProperty()
    
    def __str__(self):
        return self.name

class Post(models.BaseModel):
    author = db.UserProperty()
    title = db.StringProperty(required=True, verbose_name=u'标题')
    tag = db.StringProperty(verbose_name=u'标签')
    content = db.TextProperty(required=True, verbose_name=u'内容')
    create_time = db.DateTimeProperty(auto_now_add=True)
    update_time = db.DateTimeProperty(auto_now=True)
    category = db.ReferenceProperty(Category, required=False, verbose_name=u'类别')
    is_published = db.BooleanProperty(verbose_name=u'已发布')
    
    def get_absolute_url(self) :
        return '/post/%s/'%self.key().id()
